using UnityEngine;

namespace VoxelEngine.Utils
{
	public static class TransformUtils
	{
		public static void SetPositionX(this Transform transform, float x)
		{
			Vector3 position = transform.position;
			position.x = x;
			transform.position = position;
		}

		public static void SetPositionY(this Transform transform, float y)
		{
			Vector3 position = transform.position;
			position.y = y;
			transform.position = position;
		}

		public static void SetPositionZ(this Transform transform, float z)
		{
			Vector3 position = transform.position;
			position.z = z;
			transform.position = position;
		}

		public static void SetLocalPositionX(this Transform transform, float x)
		{
			Vector3 localPosition = transform.localPosition;
			localPosition.x = x;
			transform.localPosition = localPosition;
		}

		public static void SetLocalPositionY(this Transform transform, float y)
		{
			Vector3 localPosition = transform.localPosition;
			localPosition.y = y;
			transform.localPosition = localPosition;
		}

		public static void SetLocalPositionZ(this Transform transform, float z)
		{
			Vector3 localPosition = transform.localPosition;
			localPosition.z = z;
			transform.localPosition = localPosition;
		}

		public static void SetParentAndKeepScale(this Transform transform, Transform parent)
		{
			Vector3 localScale = transform.localScale;
			transform.SetParent(parent);
			transform.localScale = localScale;
		}
	}
}
